package cn.school.web.controller.system;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.school.common.annotation.Log;
import cn.school.common.core.controller.BaseController;
import cn.school.common.core.domain.AjaxResult;
import cn.school.common.enums.BusinessType;
import cn.school.system.domain.BiCashApply;
import cn.school.system.service.IBiCashApplyService;
import cn.school.common.utils.poi.ExcelUtil;
import cn.school.common.core.page.TableDataInfo;

/**
 * 提现申请信息Controller
 *
 * @author asheng
 * @date 2023-12-25
 */
@RestController
@RequestMapping("/system/cashApply")
public class BiCashApplyController extends BaseController
{
    @Autowired
    private IBiCashApplyService biCashApplyService;

    /**
     * 查询提现申请信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:cashApply:list')")
    @GetMapping("/list")
    public TableDataInfo list(BiCashApply biCashApply)
    {
        startPage();
        List<BiCashApply> list = biCashApplyService.selectBiCashApplyList(biCashApply);
        return getDataTable(list);
    }

    /**
     * 导出提现申请信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:cashApply:export')")
    @Log(title = "提现申请信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BiCashApply biCashApply)
    {
        List<BiCashApply> list = biCashApplyService.selectBiCashApplyList(biCashApply);
        ExcelUtil<BiCashApply> util = new ExcelUtil<BiCashApply>(BiCashApply.class);
        util.exportExcel(response, list, "提现申请信息数据");
    }

    /**
     * 获取提现申请信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:cashApply:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(biCashApplyService.selectBiCashApplyById(id));
    }

    /**
     * 修改提现申请信息
     */
    @PreAuthorize("@ss.hasPermi('system:cashApply:edit')")
    @Log(title = "提现申请信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BiCashApply biCashApply)
    {
        if(biCashApply.getStatus()==3){
            biCashApply.setCompleteTime(new Date());
        }
        return toAjax(biCashApplyService.updateBiCashApply(biCashApply));
    }

    /**
     * 删除提现申请信息
     */
    @PreAuthorize("@ss.hasPermi('system:cashApply:remove')")
    @Log(title = "提现申请信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(biCashApplyService.deleteBiCashApplyByIds(ids));
    }
}
